package homeWork.four.demo4;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2022-11-30
 * Time: 18:25
 */
public class Book {
    //1.定义一Book类，要求包含书名、作者姓名、出版社、价钱四个属性，
    //并分别定义两个构造方法（带参数的、不带参数的）以及显示输出相关信息的方法；
    //同时在主类中创建相应的Book对象,对两种构造方法的初始化效果进行测试。

    private String name;//书名
    private String author;//作者姓名
    private String publisher;//出版社
    private double price;//价钱

    public Book(){
        this.name = "java并发编程艺术";
        this.author = "sfx";
        this.price = 78.23;
        this.publisher = "新华出版社";
    }

    public Book(String name, String author, String publisher, double price) {
        this.name = name;
        this.author = author;
        this.publisher = publisher;
        this.price = price;
    }

    @Override
    public String toString() {
        return "书籍信息 : {" +
                "name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", publisher='" + publisher + '\'' +
                ", price=" + price +
                '}';
    }
    public static void main(String[] args) {
        Book book1 = new Book();
        System.out.println(book1);
        Book book2 = new Book("西游记","吴承恩","机械工业出版社",
                88.23);
        System.out.println(book2);
    }
}
